<?php
namespace api\modules\v1\models\coin;

use api\modules\v1\models\Common;
use common\models\Functions;
use common\models\Status;
use yii\base\Exception;
use Yii;
/**
 * Class UserLevel
 * @package api\modules\v1\models\user
 */
class CoinRechargeSetting extends \common\models\coin\CoinRechargeSetting
{

    //金币列表
    public function getList() {
        try {
            $user = Yii::$app->getUser()->getIdentity()->toArray();

            $where['is_delete'] = Status::COMMON_IS_NOT_DELETE;
            $andWhere = [];
            $list = static::getByAndWhere($where,$andWhere);

            $data['coin'] = $user['coin'];
            $tmp = [];
            foreach ($list as $key => $value) {
                $tmp[] = [
                    'id' => (int) $value['id'],
                    'name' => $value['name'],
                    'money' => (float) $value['money'],
                    'coin' => (float) $value['coin'],
                    'ios_id' => (string) $value['ios_id'],
                ];
            }
            $data['list'] = $tmp;
            return Functions::formatRestAPI(0, '', $data);
        } catch ( Exception $e ) {
            return Functions::formatRestAPI(1, $e->getMessage());
        }
    }

}
